InstancesΒΆ

One million instances generated with a single Instances node.

The Help > Samples > Procedural Instances sample project.

The procedural instancing workflow

The Guerilla procedural instancing workflow is a solution to render a high (millions+) number of instances. The procedural instancing generates instances at render time, keeping the complexity at the end of the rendering process. The simulation and the export processes stay light.

The Library/Procedurals/HairAndFur procedural for all the procedural attributes details. If you are using Yeti®, XGen® or Golaem®, you may not need to use the procedural instancing. Guerilla Render includes a XGen® plug-ins and Yeti® provides a RenderMan® DSO that is directly used in Guerilla Render. Golaem® provides a Guerilla Render DSO. See the TD Guide/Third Party Tools/Yeti, TD Guide/Third Party Tools/XGen and TD Guide/Third Party Tools/Golaem sections for details.

Generate the instances

The Instance node is a procedural geometry node that generates instances. The instances inherit the instance meshes attributes and shaders. The Instance node has to be linked to a scalp mesh, some instance meshes and some guide curves to drive the instances orientation if required.

The instance meshes inherit the SceneGraphNode -> Hidden attribute and the Sets attributes from the Instances node. Create an Instances procedural node
  1. Create a Procedurals/Instances node.

The scalp mesh

The scalp is the mesh on which the instances are generated.

Our scalp mesh in red, the instances generated on the scalp mesh.

Connect the scalp using the linker

Use this method to get an OpenGL feedback of the procedural.

  1. Select the Instances procedural node.
  2. Open the 'Procedural' tab.
  3. Press the 'Scalp -> Edit' button.
  4. In the linker window, select in the right column the scalp mesh.

Connect the scalp using Sets

Use this method to connect the procedural using the RenderGraph. This connection method won't work with OpenGL.

  1. Put the scalp objects in a specific set, like "Scalp" using the RenderGraph.
  2. Select the Instances procedural node.
  3. Add to the attribute Instances -> Procedural -> Scalp Set the new set.
The User Guide/Scene Graph/Set chapter to learn how to put some objects in the sets.

The instance meshes

The instance meshes are the meshes the procedural will instanciate.

The procedural is able to instanciate group of objects.

Our instance meshes, the instances generated on the scalp mesh.

Connect the instance meshes using the linker

Use this method to get an OpenGL feedback of the procedural.

  1. Select the Instances procedural node.
  2. Open the 'Procedural' tab.
  3. Press the 'Instances -> Edit' button.
  4. In the linker window, select in the right column all the instance meshes or the group nodes.

Connect the instance meshes using Sets

Use this method to connect the procedural using the RenderGraph. This connection method won't work with OpenGL.

  1. Put the instance meshes ot the group nodes in a specific set, like "Instances" using the RenderGraph.
  2. Select the Instances procedural node.
  3. Add to the attribute Instances -> Procedural -> Instances Set the new set.
The User Guide/Scene Graph/Set chapter to learn how to put some objects in the sets.

Deal with multiple instance meshes

By default, if multiple instance meshes are connected to the Instance node, the procedural will instanciate all the meshes (or all the child meshes of the group) at every instance.

You may want to randomly select different set of meshes at every instances. To do that, you have to mark every instance meshes of the same object with an ObjectName attribute.

  1. Select all the meshes of a same instance object.
  2. In the SceneGraphNode -> Dynamic Attributes section, type 'ObjectName', select string and press the Add button.
  3. Set the new ObjectName attribute with the object name.
  4. Do that for every instance objects.

On the left, the two letter meshes have the same ObjectName attributes. On the right, the two letter meshes with different ObjectName attributes.

It is also possible to add the ObjectName attribute using the RenderGraph' MaterialOverride node. Type 'ObjectName' in the Name editbox, select string and press 'Add'. Control multiple instance meshes density

By default, each instance type is selected at random, with identical probability for each type. Add a Density### attribute on the scalp, where ### matches the instance ObjectName attribute, to control the density of the instance. For instance, if the ObjectName value of the instance is 'TreeA', then the scalp attribute must be named 'DensityTreeA'.

The DensityA controls the ratio of A letters, and so on. There are roughly 2 times more B than A, and 10 times more C than A.

Density attributes can also be subshaders. The instances densities will be varying over the scalp surface instead of being constant, allowing to create patch of different populations over the scalp.

Control an instancing attribute with a sub shader

Most instancing attributes, like the density or the orientation, can be controlled by a scalp objects sub shader, like a simple texture, or any other sub shader expression. In the Library/Procedurals/HairAndFur procedural documentation, look for the attributes named Shader Out. Those attributes defines the name of the scalp object sub-shader to use to control the instancing attribute.

The scale of the instances is controlled by the Instances -> Procedural -> Length attributes like for the fur. Add a texture sub shader on the scalp objects to control an instancing attribute (Density here)
  1. In the RenderGraph, add on the scalp objects a RenderGraph/MaterialOverride node.

  2. In the MaterialOverride node, add a float attribute named like the name defined in the Instances procedural, Density here.

  3. Drag and drop your mask texture on the edit box.

The density texture, and the instances using the density texture.

The User Guide/Shading/Sub-Shaders and Textures section for the details about the sub-shaders. Please note the sub shader has to be put on the scalp objects not the procedural node.

Orient the instances

The instances can be oriented or not. To orient the instances, you have to paint direction maps in a painting tool (like Mari®) or export some guides from any third party grooming solution (like Maya® Hair or Shave and Haircut®). Then export everything in Guerilla Render.

The procedural instances with random orientation, oriented using a texture sub shader and using guide curves.

Using a texture sub shader

The simplest solution to orient the instances is to use a texture sub shader. There is two types of textures. The polar maps, generated by Maya Fur, and the direction maps, generated by Mari®.

The polar map, the instances oriented by the polar map, the direction map and the instances oriented by the direction map.

Use a texture sub shader to orient the instances
  1. Set the Instances -> Procedural -> Orientation -> Polar -> Polar Shader Mode attribute to Polar or Direction.
  2. As explained before, add to the scalp objects color sub shader named Polar and drop your texture into it.
The Polar sub shader must be a Color attribute. The texture gamma should be set to Linear.

Using guide curves

Another solution to orient the instances is to use guide curves. The guide curves can be simulated in a third party tool. The procedural instances interpolates the guides to get the instances orientation and inclinaison.

The guides curves which guide the instances, the generated instances.

The guides can be any kind of curves. For example :

  1. A Maya® Hair node with guides inside
  2. A group node with Maya® curves inside
  3. A Shave And Haircut® node
  4. Alembic curves

Connect the guide curves using the linker

Use this method to get an OpenGL feedback of the procedural.

  1. Select the Instances procedural node.
  2. Open the 'Procedural' tab.
  3. Press the 'Guides -> Edit' button.
  4. In the linker window, select in the right column the guide curves object.

Connect the guide curves using Sets

Use this method to connect the procedural using the RenderGraph. This connection method won't work with OpenGL.

  1. Put the guide curves object objects in a specific set, like "Guides" using the RenderGraph.
  2. Select the Instances procedural node.
  3. Add to the attribute Instances -> Procedural -> Guides Set the new set.
The User Guide/Scene Graph/Set chapter to learn how to put some objects in the sets.

Bake the implantation

If you are doing an animation, you probably want the instances implantation to be consistent over time to avoid flicking. To do that, you have to bake the fiber implantation.

Bake the implantation
  1. Select the Instances procedural node.
  2. Turn the 'Implantation -> Implantation Mode' to 'Bake'
  3. Wait for an OpenGL update or render the procedural
  4. Turn the 'Implantation -> Implantation Mode' to 'Read'

Now the implantation is always the same. The Implantation parameters are no longer used.

Shading

The ST attribute

Use a texture in the instances using the scalp texture coordinates
  1. Enable the Instances -> Procedural -> Attributes-> Generate ST attribute. The st coordinates are stored in the surf_st shader attribute.
  2. Add this sub shader to the instance Surface -> Diffuse Color attribute

The scalp texture coorindates have been transfered to each instance and used in the instance shader to read a texture.

The ID attribute

Get a random value per instance using the Id attribute
  1. Enable the Instances -> Procedural -> Attributes -> Generate ID attribute. The ID coordinates are stored in the id shader attribute.
  2. Add this sub shader to the instance Surface -> Diffuse Color attribute

Every instance object has a random diffuse color value.

Other attributes

The procedural can also transfer the clump ID in the clumpid shader attribute and the surface normal in the surf_N shader attribute.